//*******************************************************************
//	created:	21:4:2011   19:52
//	filename: 	stringhelper.h
//	author:		tiamo
//	purpose:	string helper
//*******************************************************************

#pragma once

//
// string helper
//
namespace utils
{
	//
	// utf8 -> wchar_t
	//
	UniString utf8ToWide(char const* inputString, uint32_t inputLength = -1);

	//
	// utf8 -> wchar_t
	//
	inline UniString utf8ToWide(Utf8String const& inputString)				{return utf8ToWide(inputString.c_str(), static_cast<uint32_t>(inputString.length()));}

	//
	// wchar_t -> utf8
	//
	Utf8String wideToUtf8(wchar_t const* inputString, uint32_t inputLength = -1);

	//
	// wchar_t -> utf8
	//
	inline Utf8String wideToUtf8(UniString const& inputString)				{return wideToUtf8(inputString.c_str(), static_cast<uint32_t>(inputString.length()));}

	//
	// hex string -> binary
	//
	void hexToBinary(UniString const& inputString, uint8_t* binaryBuffer, uint32_t bufferLength);

	//
	// binary -> hex string
	//
	UniString binaryToHex(uint8_t const* binaryBuffer, uint32_t bufferLength);

	//
	// json encoding
	//
	UniString encodeJSON(UniString const& inputString);

	//
	// escape xml
	//
	UniString escapeXml(UniString const& xmlString);
};
